<php>
$city_name = $city_name?$city_name:'所在城市';
$area_list      = D('area')->select();
$area_list_json = json_encode($area_list);

$cityid2name = array();
if($area_list){
    foreach ($area_list as $rs) {
        $cityid2name[$rs['id']] = $rs['name'];
    }
}

$multi_city_field = $multi_city_field?$multi_city_field:'city_ids';
if($info[$multi_city_field]){
	$city_id_list = explode(',',$info[$multi_city_field]);
}

//是否显示国家
$is_country   = $is_country?$is_country:0;
//是否包含HTML
$is_wrap_html = $is_wrap_html?$is_wrap_html:1;
//国家
$country_id  = $info['country_id']?$info['country_id']:1;
//省份
$province_id = is_null($info['province_id'])==false?$info['province_id']:4;
//城市
$city_id     = is_null($info['city_id'])==false?$info['city_id']:60;
//县区
$area_id     = is_null($info['area_id'])==false?$info['area_id']:587;

</php>
<eq name="is_wrap_html" value="1">
<div class="mod_data">
	<div class="name">{$city_name}</div>
	<div class="input_data" <neq name="city_disabled" value="true">style="width:650px"</neq>>
</eq>
		<eq name="is_country" value="1">
		<eq name="city_disabled" value="true">
		{$cityid2name[$country_id]}
		<else/>
		<select name="country_id" class="country_id" datatype="*">
			<option value="">-国家-</option>
			<volist name="area_list" id="area_rs">
			<eq name="area_rs.parentid" value="0">
			<option value="{$area_rs['id']}" <eq name="area_rs.id" value="$country_id">selected</eq>>{$area_rs['name']}</option>
			</eq>
			</volist>
		</select>
		</eq>
		</eq>
		<eq name="city_disabled" value="true">
		{$cityid2name[$province_id]}
		<else/>
		<select name="province_id" class="province_id" datatype="*">
			<option value="">-省份-</option>
			<volist name="area_list" id="area_rs">
			<eq name="area_rs.parentid" value="$country_id">
			<option value="{$area_rs['id']}" <eq name="area_rs.id" value="$province_id">selected</eq>>{$area_rs['name']}</option>
			</eq>
			</volist>
		</select>
		</eq>

		<eq name="city_disabled" value="true">
		{$cityid2name[$city_id]}
		<else/>
		<select name="city_id" class="city_id" datatype="*">
			<option value="">-城市-</option>
			<volist name="area_list" id="area_rs">
			<eq name="area_rs.parentid" value="$province_id">
			<option value="{$area_rs['id']}" <eq name="area_rs.id" value="$city_id">selected</eq>>{$area_rs['name']}</option>
			</eq>
			</volist>
		</select>
		</eq>

		<eq name="is_area_id" value="1">
		<eq name="city_disabled" value="true">
		{$cityid2name[$area_id]}
		<else/>
		<select name="area_id" class="area_id">
			<option value="">-县区-</option>
			<volist name="area_list" id="area_rs">
			<eq name="area_rs.parentid" value="$city_id">
			<option value="{$area_rs['id']}" <eq name="area_rs.id" value="$area_id">selected</eq>>{$area_rs['name']}</option>
			</eq>
			</volist>
		</select>
		</eq>
		</eq>
		
<eq name="is_wrap_html" value="1">
		<eq name="is_multi_city" value="1">
		<span class="btn1 add_city_ids">添加</span>
		<span class="Validform_checktip"></span>
		<div class="city_id_list">
			<volist name="city_id_list" id="id">
			<li>
				{$cityid2name[$id]}<input type="hidden" name="{$multi_city_field}[]" value="{$id}">
				<span onclick="$(this).parent().remove();">X</span>
			</li>
			</volist>
		</div>
		</eq>
	</div>
</div>
</eq>
<script type="text/javascript">
	$(".add_city_ids").click(function(){
		<eq name="is_area_id" value="1">
			city_id   = $("select.area_id option:selected").val();
			city_name = $("select.area_id option:selected").text();
			if(city_id <= 0){
				msgbox('请选择地区！','error');
				return;
			}
			exist_area_id = $(this).parent().find(".city_id_list input[value='"+city_id+"']").val();
			if(exist_area_id==city_id){
				msgbox('您选择地区已存在！','error');
				return;
			}
		<else/>
			city_id   = $("select.city_id option:selected").val();
			city_name = $("select.city_id option:selected").text();
			if(city_id <= 0){
				msgbox('请选择城市！','error');
				return;
			}
			exist_city_id = $(this).parent().find(".city_id_list input[value='"+city_id+"']").val();
			if(exist_city_id==city_id){
				msgbox('您选择城市已存在！','error');
				return;
			}
		</eq>

		html = '<li>';
		html += city_name+' <input type="hidden" name="{$multi_city_field}[]" value="'+city_id+'">';
		html += '<span onclick="$(this).parent().remove();">X</span>';
		html +=	'</li>';
		$(this).parent().find(".city_id_list").append(html);
	});
	var area_list = {$area_list_json};
	$("select.country_id").change( function() {
		country_id = $("select.country_id option:selected").val();
		var city_option = '<option value="">-省份-</option>';
		$.each(area_list, function(i){
			if(area_list[i]['parentid']==country_id){
				id   = area_list[i]['id'];
				name = area_list[i]['name'];
				city_option += '<option value="'+id+'">'+name+'</option>';
			}
		});
		//省份
		$(".province_id").html(city_option);
		//城市
		$(".city_id").html('<option value="">-城市-</option>');

		//判断是否显示县区
		<eq name="is_area_id" value="1">
		$(".area_id").html('<option value="">-县区-</option>');
		</eq>
	});
	$("select.province_id").change( function() {
		province_id = $("select.province_id option:selected").val();
		var city_option = '<option value="">-城市-</option>';
		$.each(area_list, function(i){
			if(area_list[i]['parentid']==province_id){
				id   = area_list[i]['id'];
				name = area_list[i]['name'];
				city_option += '<option value="'+id+'">'+name+'</option>';
			}
		});
		$(".city_id").html(city_option);
		<eq name="is_area_id" value="1">
		$(".area_id").html('<option value="">-县区-</option>');
		</eq>
	});
	<eq name="is_area_id" value="1">
	$("select.city_id").change( function() {
		city_id = $("select.city_id option:selected").val();
		var city_option = '<option value="">-县区-</option>';
		$.each(area_list, function(i){
			if(area_list[i]['parentid']==city_id){
				id   = area_list[i]['id'];
				name = area_list[i]['name'];
				city_option += '<option value="'+id+'">'+name+'</option>';
			}
		});
		$(".area_id").html(city_option);
	});
	</eq>
</script>